$.ajaxSetup ({ 

      cache: false //关闭AJAX相应的缓存 

  });
function uploadAttach(basePath){
	$("#attach_upload").ajaxSubmit(function(data){
		var item = $.parseJSON(data);
		$("#attach_list").append('<li><a href="'+basePath+item.filePath+'" class="a1" target="_blank">'+item.fileName+'</a><a class="a2" href="javascript:void(0);" filePath="'+item.filePath+'" class="cancl" onclick="cancelAttach(this)">取消</a></li>');
	});
	return false;
}

function cancelAttach(obj){
	var filePath = $(obj).attr("filePath");
	$.post("mail!cancelAttach.do",{
		'filePath':filePath
	},function(data){
		if(data!=null){
			var ret = $.parseJSON(data);
			if(ret.success == 'true'){
				$(obj).parent().remove();
			}
		}
	});
}


function deleteMail(messageId){
	if(confirm("你确定要删除邮件吗？")){
		$.post("mail!delete.do",{
			messageId:messageId
		},function(data){
			var ret = $.parseJSON(data);
			if(ret.success == 'true'){
				window.location.reload();
			}else{
				alert(ret.msg);
			}
		});
	}
}

function uploadUser(){
	var filename = $("#userfileform .file");
	if(filename.val() == null || filename.val() == ''){
		alert('请先选择文件');
		return;
	}
	$("#upload_user_role_id").val(editRoleId);
	$("#userfileform").ajaxSubmit(function(data){
		var ret = $.parseJSON(data);
		/*
		var html = '<input type="file" name="userfile" class="file" onchange="uploadUser();">';
		$("#userfileform .file").remove();
		$("#userfileform").append(html);
		*/
		alert(ret.msg);
	});
	return false;
}
